home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
An Invitation to the Roland World of Music
/
Roland - An Invitation To The Roland World Of Music.bin
/
specs
/
hexkey.txt
< prev
next >
Wrap
Text File
|
1994-06-03
|
6KB
|
124 lines
WHAT THE HEX?
============================================================
** This is a reprint from KEYBOARD magazine's February 1994 issue.**
MIDI messages can be notated numerically in one of three ways: binary, decimal, or hexadecimal. The
method the microprocessors in your MIDI equipment prefers is binary, in which each of the eight bits in a
data byte is represented by either a 0 or a 1. You, though you may not realize it yet, prefer to use the
decimal system, in which each of your ten fingers is represented by an Arabic numeral, the familiar 0
though 9. Hexadecimal notation (or "hex" as it is affectionately known), makes working with MIDI
messages easier than either of the other two systems. Hex is base 16, with the rightmost column being the
"ones" column, and the column to the left being the "16s". Our decimal system only has 10 symbols for
representing numbers, but hex must have 16. To accommodate these six unrepresented values, we use the
letters A through F to represent the values from 10 through 15 decimal. A value of 16 appears in hex as
10. (Some publications use an "H" after a hex number, to make it easy to tell the difference between 10 in
decimal and 10H, which would be 16 in decimal.)
Contrary to popular belief, the engineers who invented the hex system did not have eight fingers on each
hand. They did, however, have plenty of eight-bit bytes in binary to worry about. Since four digits of
binary can represent a total of 16 different values, we can quickly translate an eight-digit binary number
into a two-digit hex number. It's easier to recognize status bytes and MIDI channels when they are in hex
notation; consequently, it's easier to keep track of MIDI messages when inserting them in a sequencer
track or programming your Sound Canvas in Micro Edit mode, which displays all parameters in hex.
MIDI system-exclusive messages contain hexadecimal respresentations of a given instrument's internal
parameter settings.
The Sound Canvas's sys-ex messages are divided into three sections: header, body, and end. The header is
virtually identical for most of the sys-ex messages you'll use with the Sound Canvas. It simply identifies
this message as sys-ex data for a Roland GS instrument.
F0 Begin sys-ex
41 Roland ID
10 Device ID
42 GS Model ID
12 Data Set Command
The body consists of a three-byte address, any number (up to 256) of data bytes, and the infamous Roland
checksum. Each editable parameter in the Sound Canvas has its own sys-ex address. This allows you to
send a sys-ex message to a specific address without bothering the neighboring parameters. Look for the
Parameter Base Address near the back of your Sound Canvas manual, then find the table labeled Patch
Parameters for the addresses used in these examples.
For our first example, we'll change the reverb from the Hall 2 default setting to delay. Under Patch
Parameters, Reverb Macro is listed next to the address 40 01 30. We enter those numbers as our three-byte
address.
40 \
01 Address
30 /
The address is a starting point for the data bytes to enter memory. The first data byte is entered at that
address, and the remaining data bytes automatically flow to the following address locations. For Reverb
Macro, the manual indicates there are eight choices, of which delay is number 06, so 06 becomes our first
and only data byte.
06 Data
Next, we need to compute a checksum for this message. The checksum is used to protect your Sound
Canvas from receiving corrupted data by ensuring that the address and data bytes follow a precise
mathematical formula. Corruption is usually not a problem when creating small messages, as in these
examples, but can be when one missing byte in a bulk dump can ruin a dozen of your favorite patches!
Here's a simple translation of the checksum formula:
80 - (sum of address bytes + sum of data bytes) = Checksum
If the sum of the address and data bytes is greater than 80 (hex), the result will be a negative checksum. In
that case, subtract 80 from the address and data sum as often as necessary until the sum is less than 80, so
that the subtraction that computes the checksum yields a positive result. For our example, we have:
80 - (40 + 01 + 30 + 06) = Checksum
80 - 77 = Checksum
09 = Checksum
But hypothetically, if the sum of the address and data bytes had been greater than 80 (hex):
80 - (80 + 40 + 01 + 40 + 06) = Checksum
80 - 107 = Checksum (negative, so subtract 80)
80 - (107 - 80) = Checksum (still negative, so subtract 80 again)
80 - (87 - 80) = Checksum (positive)
79 = Checksum
So our body now becomes:
40 \
01 Address
30 /
06 Data
09 Checksum
If you're new to hex, you may be confused to see an equation like 80 - 77 = 09. You may find it easier to
convert all the values to decimal, perform the subtraction, and then convert back. In this case, 128 (equal
to 80 hex) minus 119 (equal to 77 hex) equals 9.
The checksum is followed by the end-of-exclusive byte F7. Our entire message would be:
F0 41 10 42 12 40 01 30 06 09 F7
For the Sound Canvas, there is a slight variation on this message format when we want to address
parameters for a single part. Look in the Patch Parameter addresses in the manual to find:
40 1n 02 Rx Channel
40 1n 03 Rx Pitch-Bend
Notice all the addresses past this point have an "n" in the second address byte. In hex, the 16 Sound
Canvas parts are numbered starting with 1. For part 1, n=1, for part 2, n=2, and so on. For part 10, n=0,
after which part 11 is numbered A and so on. For this example, let's say we want to change part 1 from
MIDI channel 1 to channel 16, and not have it respond to pitch-bend messages. First, we use the same
five-byte header, followed by the appropriate starting address as shown in the Patch Paramater list -- with
n=part 1 -- and two data bytes, since we're changing two consecutive parameters:
Header F0 41 10 42 12
Address 40 11 02
Data 0F 00
Our checksum for this message would be:
80 - (40 + 11 + 02 + 0F + 00) = Checksum
80 - 62 = Checksum
1E = Checksum
Yielding:
F0 41 10 42 12 40 11 02 0F 00 1E F7
Give these examples a try. With a little practice you too can become an official "hexhead."